package com.production.CoursePlatform.mapper;

import com.production.CoursePlatform.entity.Attachment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AttachmentMapper {

    @Insert("INSERT INTO attachment (a_name, uploadID, a_type, a_path, a_size) " +
            "VALUES (#{aName}, #{uploadID}, #{aType}, #{aPath}, #{aSize})")
    @Options(useGeneratedKeys = true, keyProperty = "aID")
    void insertAttachment(Attachment attachment);

    @Select("SELECT * FROM attachment WHERE a_id = #{aID}")
    Attachment selectAttachmentById(int aID);
}

